﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PrjBaseWithAuth4.Domain.Entities;
using PrjBaseWithAuth4.Domain.Concrete;
using System.Linq.Expressions;

namespace PrjBaseWithAuth4.Domain.Abstract
{
    public interface ICommonRepository
    {
        /// <summary>
        /// 获取工程中的使用数据库上下文。
        /// </summary>
        /// <returns></returns>
        EFDbContext getEFDbContext();

        /// <summary>
        /// 获取站点对象。
        /// </summary>
        /// <param name="portalId"></param>
        /// <returns></returns>
        S_Portal getPortalById(int portalId);

        /// <summary>
        /// 检查T实体中，是否存储指定条件的记录。
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="anyLambda">条件表达式</param>
        /// <returns></returns>
        bool CheckExists<T>(Expression<Func<T, bool>> anyLambda) where T : class;

        T FirstOrDefault<T>(Expression<Func<T, bool>> anyLambda) where T : class;
    }
}
